﻿using MassTransit;
using Order.API.Services.Commands;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Order.API.Services.Jobs
{
    public class OrderCreatedJob
        : IJob
    {
        private readonly ISendEndpoint _busEndpoint;
        public OrderCreatedJob()
        {
            _busEndpoint = Startup.SendEndpoint;
        }
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                await _busEndpoint.Send(new CreateOrderCmd() { Id = Guid.NewGuid().GetHashCode(), UserId = Guid.NewGuid().GetHashCode() });
            }
            catch (Exception ex)
            {

                throw;
            }
        }
    }
}
